<?php
require_once("../includes/config.php");
include DIR_INCLUDES_FT.'bootstrap.php';
try{
	$conection->beginTransaction();
	
	if(isset($_POST['id']) && $_POST['id'] != ''){
		$categoria = Doctrine::getTable("Categorias")->find($_POST['id']);
	} else {
		$categoria = new Categorias();
	}
	
	$categoria->nome= $_POST['nome'];
	$categoria->save();
	
	$conection->commit();
	header("location: ".DIR_WS."redirect.php?refere=".$_SERVER['HTTP_REFERER']);
} catch (Exception $e){
	$conection->rollback();
	header("location: ".DIR_WS."error_message.php?refere=".$_SERVER['HTTP_REFERER']);
}
?>